import 'package:casdon/core/network/network_notifier.dart';
import 'package:casdon/core/network/network_state.dart';
import 'package:casdon/modules/device/application/notification/product_category_notifier.dart';
import 'package:casdon/modules/device/data/api/ciot_pairNet_guid_info_api.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';

class CiotPairNetGuidNotifier
    extends NetworkNotifier<List<CiotPairNetGuidInfo>, String> {
  String? _pid;

  void setPid(String pid) {
    if (_pid == pid) return;
    _pid = pid;
    refresh();
  }

  @override
  Future<List<CiotPairNetGuidInfo>> fetchData(String pid) async {
    if (pid.isEmpty) {
      return const [];
    }
    return ref.read(deviceRepositoryProvider).getCiotPairNetGuid(pid);
  }

  @override
  String get params => _pid ?? '';
}

final ciotPairNetGuidNotifierProvider =
    NotifierProvider<CiotPairNetGuidNotifier,
        NetworkState<List<CiotPairNetGuidInfo>>>(CiotPairNetGuidNotifier.new);
